<template>
  <transition name="slide-to-right">
    <div class="content">
      <div class="content-wrapper" v-if="bookAvailable">
        <div class="content-title">目录</div>
        <div class="content-item" v-for="(item,index) in navigation.toc" :key="index" @click="jumpTo(item.href)">
          <span class="text">{{item.label}}</span>
        </div>
      </div>
      <div class="empty" v-else>
        加载中...
      </div>
    </div>
  </transition>
</template>

<script>
export default {
  name: 'content-view',
  props: {
    ifShowContent: {
      type: Boolean
    },
    bookAvailable: {
      type: Boolean
    },
    navigation: {
      type: Object
    }
  },
  data () {
    return {
    }
  },
  methods: {
    jumpTo (target) {
      this.$emit('jumpTo', target)
    },
    //返回上一级
    prev() {
      this.$router.go(-1);
    },
  }
}
</script>

<style lang="scss" scoped>
  @import '~styles/global';
  .content{
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    width: 25%;
    padding: 4% 0;
    box-sizing: border-box;
    // background-color: rgb(255, 255, 255);
    color: white;
    background: #743d0d;
    box-shadow: 0 px2rem(-8) px2rem(8) rgba(0,0,0,0.15);
    z-index: 102;
    overflow-x: hidden;
    overflow-y: auto;
    // .iconback{
    //   color: white;
    //   font-weight: 600;
    //   position: absolute;
    //   left: 0.3rem;
    //   top: 0.5rem;
    // }
    .content-wrapper{
      display: flex;
      flex-direction: column;
      padding: 0 px2rem(10);
      .content-title{
        flex: 0 0 px2rem(50);
        font-size: px2rem(24);
        line-height: px2rem(50);
      }
      .content-item{
        cursor: pointer;
        flex: 0 0 px2rem(50);
        .text{
          font-size: px2rem(14);
          display: block;
          line-height: px2rem(50);
          height: px2rem(50);
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          width: 100%;
          box-sizing: border-box;
        }
      }
    }
    .empty{
      width: 100%;
      height: 100%;
      @include center;
      font-size: px2rem(16);
    }
  }
</style>
